<template>
	<view class="home" v-if="isLogin">
		<view class="banner">
			<image src="http://klwl-file.oss-cn-shenzhen.aliyuncs.com/202105/jhstest/49642875526530.png"
				mode="widthFix"></image>
			<view class="banner-title">
				<image class="av-img" :src="vuex_adminuser.img || '../static/logo.png'" mode=""></image>
				<view class="tit">
					<text class="pb-20">{{ vuex_adminuser.name }}</text>
					<text>{{ vuex_adminuser.phone }}</text>
				</view>
			</view>
			<view class="setting" @click="open">
				<u-icon name="setting" color="#fff" size="40"></u-icon>
			</view>
		</view>

		<view class="transaction">
			<view class="transaction-title">实时交易</view>
			<view class="echart">
				<div class="progress_box">
					<cmd-progress type="dashboard" :percent="percentage" stroke-color="#307aff" gap-degree="150"
						:stroke-width="6" :width="210" stroke-shape="round" :showInfo="false"></cmd-progress>
					<div class="xian_box"
						:style="{ 'background-image': 'url(http://klwl-file.oss-cn-shenzhen.aliyuncs.com/202105/jhstest/54098876544126.png)' }">
					</div>
					<view class="echart-title">
						<view class="title-top mb-4 fw-bold u-font-38">{{ $price(analysis.total_amount) }}</view>
						<view class="u-font-24">订单总金额(元）</view>
					</view>
				</div>
			</view>
			<view class="num_box num-left">
				<text class="u-font-48 fw-bold">{{ analysis.order_count? analysis.order_count:0 }}</text>
				<text class="u-font-24">今日累计订单(件)</text>
			</view>
			<view class="num_box num-right">
				<text class="u-font-48 fw-bold">{{ analysis.order_money?analysis.order_money:0 }}</text>
				<text class="u-font-24">今日交易额(元)</text>
			</view>
		</view>

		<view class="nav">
			<view class="nav-item" v-for="(item, index) in navList" :key="index" @click="openItem(item.url, index)">
				<view class="img">
					<view class="iconfont u-font-46" :class="item.icon"></view>
				</view>
				<view class="">{{ item.name }}</view>
			</view>
			<view class="nav-item" v-for="(item, index) in navList.length % 4 == 0 ? 0 : 4 - (navList.length % 4)"
				:key="index">
				<view class="img" style="background-color: #fff;">
					<u-icon name="" size="30"></u-icon>
				</view>
				<view class=""></view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		adminPost
	} from '@/common/http.request.js';
	import {
		mapState
	} from 'vuex';
	import cmdProgress from '../components/cmd-progress/cmd-progress.vue';
	export default {
		components: {
			cmdProgress
		},
		data() {
			return {
				analysis: {},
				isLogin: false,
				initNav: [],
				navList: [{
						icon: 'iconfont-e68c',
						name: '产品管理',
						url: '/package/supplierSide/product/p-display/index'
					},
					{
						icon: 'iconfont-e664',
						name: '订单管理',
						url: '/package/supplierSide/order/index'
					},
					{
						icon: 'iconfont-e664',
						name: '拍卖订单',
						url: '/package/supplierSide/auctionOrder/index'
					},
					{
						icon: 'iconfont-e62a',
						name: '提现',
						url: '/package/supplierSide/Withdrawal/index'
					},
					{
						icon: 'iconfont-e62a',
						name: '拍卖提现',
						url: '/package/supplierSide/AuctionWithdrawal/index'
					},
					{
						icon: 'iconfont-e634',
						name: '核销',
						url: '/package/supplierSide/order/verifiOrder/search'
					},
					{
						icon: 'iconfont-e6b1',
						name: '支付进件',
						url: '/package/supplierSide/paymentChannel/index'
					},
					{
						icon: 'iconfont-e609',
						name: '退出登录',
						url: ''
					}
				]
			};
		},
		computed: {
			...mapState(['vuex_adminuser']),
			percentage() {
				let num;
				num = (this.analysis.order_money / this.analysis.total_amount) * 100;
				return parseInt(num || 0);
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title: this.vuex_business.name
			});
			this.$loading();
			adminPost('GetSupplierStatistics', {
				pk_id: this.vuex_adminuser.supplier_id,
				type:4
			}).then(res => {
				this.isLogin = true;
				this.$hide();
				this.analysis = res.data[0];
			});
		},
		onShow() {

		},
		methods: {
			open() {
				this.$linkTo('/package/supplierSide/setting/index');
			},
			openItem(url, idx) {
				if (Number(idx) + 1 == this.navList.length) {
					this.$u.vuex('vuex_adminuser', {});
					this.$linkTo('/package/system/login', 'redirectTo');
				}
				this.$linkTo(url);
			}
		}
	};
</script>
<style>
	page {
		background-color: #f5f5f5;
	}
</style>
<style lang="scss" scoped>
	.home {
		padding: 20rpx 0;

		.pb-20 {
			padding-bottom: 20rpx;
		}

		.mr-20 {
			margin-right: 20rpx;
		}

		.mb-4 {
			margin-bottom: 4rpx;
		}

		.banner {
			position: relative;
			margin: 0 30rpx 20rpx;

			.setting {
				position: absolute;
				right: 30rpx;
				top: 20rpx;
			}

			.banner-title {
				display: flex;
				position: absolute;
				left: 78rpx;
				top: 34rpx;
				align-items: center;

				.av-img {
					width: 110rpx;
					height: 110rpx;
					border-radius: 50%;
					overflow: hidden;
				}

				.tit {
					display: flex;
					flex-direction: column;
					margin-left: 20rpx;
					color: #fff;
				}
			}
		}

		.transaction {
			width: 696rpx;
			margin: 0 auto 20rpx;
			background-color: #fff;
			padding: 30rpx;
			position: relative;
			border-radius: 20rpx;

			.transaction-title {
				font-size: 34rpx;
				font-weight: bold;
				color: #333;
			}

			.echart {
				text-align: center;
				position: relative;
				padding-top: 46rpx;
				display: flex;
				justify-content: center;
				align-items: center;

				.progress_box {
					position: relative;

					.xian_box {
						position: absolute;
						top: 44rpx;
						left: 44rpx;
						right: 44rpx;
						height: 50%;
						background-size: 100%;
						background-repeat: no-repeat;
					}

					.echart-title {
						display: flex;
						flex-direction: column;
						align-items: center;
						position: absolute;
						top: 100rpx;
						left: 50%;
						transform: translateX(-50%);
					}
				}
			}

			.num_box {
				display: flex;
				flex-direction: column;
				align-items: center;
				position: absolute;
				bottom: 60rpx;

				&.num-left {
					left: 60rpx;
				}

				&.num-right {
					right: 60rpx;
				}
			}
		}

		.nav {
			width: 696rpx;
			margin: 0 auto;
			background-color: #fff;
			padding: 36rpx 25rpx;
			display: flex;
			border-radius: 20rpx;
			flex-wrap: wrap;
			justify-content: space-between;

			.nav-item {
				display: flex;
				// flex: 1;
				width: 25%;
				margin-bottom: 20rpx;
				flex-direction: column;
				align-items: center;

				.img {
					height: 80rpx;
					width: 80rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border-radius: 50%;
					background-color: #f2f9ff;
					margin-bottom: 20rpx;
					color: #3297ef;
				}
			}
		}
	}
</style>
